package com.leetcode.题库;

/**
 * @author 覃国强
 * @date 2022-03-16 20:02
 */
public class 题库_0485_最大连续1的个数 {


  static
  class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
      if (nums == null || nums.length == 0) {
        return 0;
      }
      int answer = 0;
      int count = 0;
      for (int num : nums) {
        if (num == 1) {
          ++count;
        } else {
          answer = Math.max(count, answer);
          count = 0;
        }
      }
      return Math.max(count, answer);
    }
  }

}
